import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { ConstConfig } from "../../../resource/ConstConfig";
import { Game } from "../../../Game";
import { KeyBoardManager } from "../../../../../com/gengine/keyBoard/KeyBoardManager";
import { GameProxy } from "../../../mvc/GameProxy";
import { SecTimerView } from "../../common/SecTimerView";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class EatBeansReliveWin
    
    export  class EatBeansReliveWin extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(335, 143);
            this.title = Language.getString(20802);
            this.titleHeight = 27;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(17, 37, 301, 95, this);
            this._btnRelive = ObjCreate.createGButton(Language.getString(20819), 117, 97, 90, 26, this);
            this._timeView = ObjCreate.createSecTimeView("", 64, 52, 214, 40, this);
            this._timeView.multiline = true;
            this._timeView.wordWrap = true;
            var loc1=this._timeView.defaultTextFormat;
            loc1.align = flash.text.TextFormatAlign.CENTER;
            loc1.leading = 4;
            this._timeView.defaultTextFormat = loc1;
            this._btnRelive.addEventListener(flash.events.MouseEvent.CLICK, this.clickReliveHandler);
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            super.createDisposedChildrenImpl();
            if (closeBtn) 
            {
                closeBtn.visible = false;
            }
            return;
        }

        public setShowMode(arg1: int=1): void
        {
            var loc1=0;
            if (EatBeansReliveWin.ReliveModeThief != arg1) 
            {
                if (EatBeansReliveWin.ReliveModeDefender == arg1) 
                {
                    this._mode = arg1;
                    this._timeView.setParse(Language.getStringByParam(80383, Language.getString(80389)));
                    loc1 = ConstConfig.instance.getValueByName("EatBeansRevivalCD");
                    if (loc1 == 0) 
                    {
                        loc1 = 20;
                    }
                    this._timeView.setLeftTime(loc1, true);
                    this._timeView.timeOutHandler = this.canReliveHandler;
                    this._btnRelive.mouseEnabled = false;
                    this._btnRelive.enabled = false;
                    this._btnRelive.label = Language.getString(20804);
                }
            }
            else 
            {
                this._mode = arg1;
                this._timeView.stop();
                this._timeView.htmlText = Language.getString(80384);
                this._btnRelive.mouseEnabled = true;
                this._btnRelive.enabled = true;
                this._btnRelive.label = Language.getString(20819);
            }
            return;
        }

        /* internal  */canReliveHandler(): void
        {
            this._timeView.setParse(Language.getStringByParam(80383, Language.getString(80388)));
            this._timeView.setLeftTime(10, true);
            this._timeView.timeOutHandler = this.clickReliveHandler;
            this._btnRelive.mouseEnabled = true;
            this._btnRelive.enabled = true;
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            if (Game.scene.mouseEnabled) 
            {
                KeyBoardManager.instance.cancelListener();
                Game.scene.mouseEnabled = false;
            }
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            if (this._reliveTimeOutId != 0) 
            {
                flash.utils.clearTimeout(this._reliveTimeOutId);
            }
            if (this._timeView) 
            {
                this._timeView.stop();
            }
            if (!Game.scene.mouseEnabled) 
            {
                KeyBoardManager.instance.addListener();
                Game.scene.mouseEnabled = true;
            }
            return;
        }

        /* internal  */clickReliveHandler(arg1: Object /* flash.events.MouseEvent */=null): void
        {
            GameProxy.copy.moveToPassPoint(1);
            if (this._timeView != null) 
            {
                this._timeView.stop();
            }
            return;
        }

        public static /* const */ReliveModeThief: int=1;

        public static /* const */ReliveModeDefender: int=2;

        /* internal */ /* var */_timeView: SecTimerView;

        /* internal */ /* var */_btnRelive: GButton;

        /* internal */ /* var */_reliveTimeOutId: int;

        /* internal */ /* var */_mode: int;
    }
